﻿using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
using System;

namespace $ext_safeprojectname$
{
    /// <summary>
    /// 
    /// </summary>
    [DependsOn(
        typeof($ext_safeprojectname$DomainModule),
        typeof(AbpEntityFrameworkCoreModule)
    )]
    public class $ext_safeprojectname$EntityFrameworkCoreModule : AbpModule
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public override void ConfigureServices(ServiceConfigurationContext context)
        {

            Console.WriteLine($"{DateTime.Now} $ext_safeprojectname$EntityFrameworkCoreModule.ConfigureServices");

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public override void PreConfigureServices(ServiceConfigurationContext context)
        {
                        System.AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
            //判断什么数据库类型
            context.Services.AddTransient<I$ext_safeprojectname$DbContext, $ext_safeprojectname$DbContext>();
            Configure<AbpDbContextOptions>(options => { options.UseNpgsql(); });
            context.Services.AddAbpDbContext<$ext_safeprojectname$DbContext>(options =>
            {
                options.AddDefaultRepositories<$ext_safeprojectname$DbContext>(includeAllEntities: true);
            });
            
            base.PreConfigureServices(context);
        }
    }
}